package org.bonorsoft.modules.user.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.bonorsoft.modules.user.entity.MobileRole;

import java.io.Serializable;
import java.util.Collection;
import java.util.List;

public interface MobileRoleMapper extends BaseMapper<MobileRole> {
    boolean removeByIds(@Param(Constants.COLLECTION) Collection<? extends Serializable> idList);

    /**
     * 根据用户ID查询角色
     *
     * @param userid 用户ID
     * @return 角色列表
     */
    public List<MobileRole> selectRolesByUserId(String userid);

    @Select("select r.id, r.data_scope from sys_role r left join sys_user_role ur on r.id = ur.id where ur.user_id = #{userid}")
    List<MobileRole> getRolesByUserId(String userid);
}
